package dl.domainmodel.factory;

import dl.domainmodel.specifier.DatabaseProduct;
import dl.domainmodel.specifier.NullProduct;
import dl.domainmodel.specifier.SpreadSheetProduct;
import dl.domainmodel.specifier.WordProcessorProduct;
import dl.domainmodel.specifier.iface.ProductSpecifier;
import dl.enumerator.ProductType;

/**
 * Factory Class
 * @author basanta
 *
 */
public class ProductFactory {

	private static java.util.HashMap storage = new java.util.HashMap();

	public static ProductSpecifier getProductSpecifier(String productType) {

		ProductSpecifier specifier = (ProductSpecifier) storage.get(productType);
		if (specifier == null)
			return NullProduct.NULL_PRODUCT;
		return specifier;
	}

	public static void register(final String key, final ProductSpecifier value) {
		storage.put(key, value);
	}

	static {
		DatabaseProduct.register();
		WordProcessorProduct.register();
		SpreadSheetProduct.register();
	}
}
